package com.ycp.erp.customer.ui.activity;

import android.annotation.SuppressLint;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jakewharton.rxbinding2.view.RxView;
import com.one.common.config.RouterPath;
import com.one.common.manager.RouterManager;
import com.one.common.model.extra.DefaultExtra;
import com.one.common.utils.StringUtils;
import com.one.common.view.base.BaseActivity;
import com.one.common.view.widget.MyTitleBar;
import com.ycp.erp.R;
import com.ycp.erp.supplier.model.bean.SupplierBean;

import java.util.concurrent.TimeUnit;

import butterknife.BindView;

/**
 * Class Des:客户详情
 * Created by bjh on 2021/9/13.
 */
@Route(path = RouterPath.CUSTOMER_DETAIL)
public class CustomerDetailActivity extends BaseActivity {
    @BindView(R.id.tvCustomerName)
    TextView tvCustomerName;
    @BindView(R.id.tvCustomerPhone)
    TextView tvCustomerPhone;
    @BindView(R.id.tvCustomerAddr)
    TextView tvCustomerAddr;
    @BindView(R.id.tvRemarks)
    TextView tvRemarks;
    @BindView(R.id.rlRecord)
    RelativeLayout rlRecord;

    @Override
    protected void initPresenter() {

    }
    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("客户详情").hideLine();
    }
    @SuppressLint("CheckResult")
    @Override
    public void initData() {
        super.initData();
        DefaultExtra defaultExtra = (DefaultExtra) getIntent().getSerializableExtra(DefaultExtra.getExtraName());
        SupplierBean obj = (SupplierBean) defaultExtra.getObj();
        tvCustomerName.setText(StringUtils.isNotBlank(obj.getName())?obj.getName():"");
        tvCustomerPhone.setText(StringUtils.isNotBlank(obj.getPhone())?obj.getPhone():"");
        tvCustomerAddr.setText(StringUtils.isNotBlank(obj.getAddr())?obj.getAddr():"");
        RxView.clicks(rlRecord).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o->{
            RouterManager.getInstance().go(RouterPath.CUSTOMER_RECORD);
        });
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_customer_detail;
    }
}
